import { request } from "../util";
export const getUserInfo = async () => {
	const result = await request.get("/admin/user/userInfo");
	return result.data;
};
export const sendMailCode = async (data: { email: string; captcha: string }) => {
	const result = await request.post("/admin/user/mailCode", data);
	return result.data;
};
export const login = async (data: { username: string; password: string; captcha: string }) => {
	const result = await request.post("/admin/user/login", data);
	return result.data;
};
export const mailLogin = async (data: { email: string; mailCode: string }) => {
	const result = await request.post("/admin/user/mailLogin", data);
	return result.data;
};
export const register = async (data: {
	username: string;
	email: string;
	mobile: string;
	password: string;
	password_repeat: string;
	captcha: string;
	gender?: number;
	mailCode: string;
	avatar?: string;
}) => {
	const result = await request.post("/admin/user/register", data);
	return result.data;
};
//todo: 服务端需要优化逻辑，有些信息不能重复
export const changeUserinfo = async (
	data: Partial<{
		username: string;
		email: string;
		mobile: string;
		gender: string;
		avatar: string;
		city: string;
		role: string;
		status: string;
		description: string;
	}>
) => {
	const result = await request.post("/admin/user/changeUserinfo", data);
	return result.data;
};

export const changePasswordWhenNoAuth = async (data: { email: string; password_new: string; password_repeat: string; captcha: string; mailCode: string }) => {
	const result = await request.post("/admin/user/changePasswordWhenNoAuth", data);
	return result.data;
};
